package artibella.ui.combos
{
	import flash.display.Sprite;
	import flash.text.AntiAliasType;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;

	import caurina.transitions.properties.ColorShortcuts;
	import caurina.transitions.Tweener;
	
	/**
	 * ...
	 * @author pbordachar
	 */
	
	public class ComboListItem extends AComboListItem
	{
		private var _txt:TextField;
		private var _format:TextFormat;
		
		public function ComboListItem( i:int ) 
		{
			super( i );
			
			ColorShortcuts.init();
			
			_initFormat();
			
			setText( String( i ) );
		}

		protected function _initFormat():void
		{
			_format = new TextFormat();
			_format.font = "Arial";
			_format.color = 0x000000;
			_format.size = 12;
		}
		
		public function setTextFormat( tf:TextFormat ):void
		{
			_format = tf;
			
			if ( _txt != null ) {
				_txt.setTextFormat( _format );
			}
		}
		
		// - - -
		
		override public function setText( str:String ):void
		{
			super.setText( str );
			
			if( _txt ) removeChild( _txt );
			
			_txt = new TextField();
			_txt.defaultTextFormat = _format;
			_txt.embedFonts = true;
			_txt.antiAliasType = AntiAliasType.ADVANCED;
			_txt.autoSize = TextFieldAutoSize.LEFT;
			_txt.multiline = false;
			_txt.wordWrap = false;
			_txt.selectable = false;
			_txt.htmlText = str;
			
			_txt.x = 5;
			_txt.y = 0;
			addChild( _txt );
			
			with ( graphics ) {
				beginFill( 0xFFFFFF, 0 );
				drawRect( 0, 0, _txt.width + 10, _txt.height + 4 );
				endFill();
			}
		}

		override public function setBackground():void
		{
		
		}
		
		// - - -
		
		override public function doROver():void
		{
			//Tweener.addTween( _txt, { _color:0x4C4C4C, time:.5 } );
			Tweener.addTween( _txt, { alpha:.5, time:.5 } );
		}
		
		override public function doROut():void
		{
			//Tweener.addTween( _txt, { _color:0x000000, time:.5 } );
			Tweener.addTween( _txt, { alpha:1, time:.5 } );
		}
	}
}